y=int(input())
v = str(y) 
if len(v)==4:
    x1=int((v)[0]) 
    x2=int((v)[1]) 
    x3=int((v)[2]) 
    x4=int((v)[3]) 
    x5=int(str(x1)+str(x2)) 
    x6=int(str(x1)+str(x2)+str(x3)) 
    x7=int(str(x1)+str(x2)+str(x3)+str(x4)) 
    x8=int(str(x2)+str(x3)) 
    x9=int(str(x2)+str(x3)+str(x4)) 
    x10=int(str(x3)+str(x4))
    a1=0 
    for i in range(1, x1+1): 
        if x1%i == 0: 
            a1 += 1 
    if a1 !=2: 
        x1=0 
    a2=0 
    for i in range(1, x2+1): 
        if x2%i == 0: 
            a1 += 1 
    if a2 !=2: 
        x2=0 
    a3=0 
    for i in range(1, x3+1): 
        if x3%i == 0: 
            a3 += 1 
    if a3 !=2: 
        x3=0 
    a4=0 
    for i in range(1, x4+1): 
        if x4%i == 0: 
            a4 += 1 
    if a4!=2: 
        x4=0 
    a5=0 
    for i in range(1, x5+1): 
        if x5%i == 0: 
            a5 += 1 
    if a5 !=2: 
        x5=0 
    a6=0 
    for i in range(1, x6+1): 
        if x6%i == 0: 
            a6 += 1 
    if a6 !=2: 
        x6=0 
    a7=0 
    for i in range(1, x7+1): 
        if x7%i == 0: 
            a7 += 1 
    if a7!=2: 
        x7=0 
    a8=0 
    for i in range(1, x8+1): 
        if x8%i == 0: 
            a8 += 1 
    if a8 !=2: 
        x8=0 
    a9=0 
    for i in range(1, x9+1): 
        if x9%i == 0: 
            a9 += 1 
    if a9 !=2: 
        x9=0 
    a10=0 
    for i in range(1, x10+1): 
        if x10%i == 0: 
            a10 += 1 
    if a10 !=2: 
        x10=0  
    s = [x1, x2, x3, x4, x5 ,x6, x7, x8, x9, x10]
    print(max(s)) 
else:
    print(0)

